ocaml: install built modules
authorIan Campbell <ian.campbell@citrix.com>
Tue, 23 Nov 2010 19:28:03 +0000 (19:28 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Tue, 23 Nov 2010 19:28:03 +0000 (19:28 +0000)
Previously the install target was having no effect because it ended up
calling the default target in the subdir Makefile instead of the
install target.

Resolve this by tying the tools/ocaml Makefiles into the generic
handling done by tools/Rules.mk.

Other changes arising in one way or another from this:
- Add libs/xl/META.in
- Update .hgignore for META files
- Create leading directories
- Remove existing module before installation in install targer
  (worksaround what appears to be a quirk of "ocamlfind install")
- Use the globally defined $(DESTDIR)
- Move "ocamlfind printfconf destdir" to a common variable,
  repurposing exising unused OCAMLDESTDIR, incorporating $(DESTDIR) at
  the same time.
- Drop a few unused variabe definitions (mainly to avoid deciding if
  $(DESTDIR) made sense for them or not.
- Pass -destdir to ocamlfind in uninstall target for symmetry with
  install target.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
14 files changed:
.hgignore
tools/ocaml/Makefile
tools/ocaml/common.make
tools/ocaml/libs/Makefile [new file with mode: 0644]
tools/ocaml/libs/eventchn/Makefile
tools/ocaml/libs/log/Makefile
tools/ocaml/libs/mmap/Makefile
tools/ocaml/libs/uuid/Makefile
tools/ocaml/libs/xb/Makefile
tools/ocaml/libs/xc/Makefile
tools/ocaml/libs/xl/META.in [new file with mode: 0644]
tools/ocaml/libs/xl/Makefile
tools/ocaml/libs/xs/Makefile
tools/ocaml/xenstored/Makefile

index 865da6dc4c0bacfeea3c2da3fb9b0794b0ea0428..3fac70041f81f56bdb67100875405b867b77cb58 100644 (file)
--- a/.hgignore
+++ b/.hgignore
 ^tools/ioemu-dir$
 ^tools/ocaml/.*/.*\.annot$
 ^tools/ocaml/.*/.*\.cmx?a$
+^tools/ocaml/.*/META$
 ^tools/ocaml/.*/\.ocamldep\.make$
 ^tools/ocaml/xenstored/oxenstored$
 ^xen/\.banner.*$
index 5171c62434d30234b7f81a463667e5f68b07f96d..9964631e5129fc596027445c8326b4656e9a6db0 100644 (file)
@@ -1,43 +1,19 @@
 XEN_ROOT = ../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-SUBDIRS_LIBS = \
-       libs/uuid libs/mmap \
-       libs/log libs/xc libs/eventchn \
-       libs/xb libs/xs libs/xl
-
 SUBDIRS_PROGRAMS = xenstored
 
-SUBDIRS = $(SUBDIRS_LIBS) $(SUBDIRS_PROGRAMS)
+SUBDIRS = libs $(SUBDIRS_PROGRAMS)
 
 .NOTPARALLEL:
 # targets here must be run in order, otherwise we can try
 # to build programs before the libraries are done
 
 .PHONY: all
-all: build
-
-.PHONY: build
-build: SUBDIRS
-
-.PHONY: SUBDIRS SUBDIRS_PROGRAMS SUBDIRS_LIBS
-SUBDIRS SUBDIRS_PROGRAMS SUBDIRS_LIBS:
-       @set -e; for d in $($@); do                     \
-               echo " === building $$d";               \
-               $(MAKE) --no-print-directory -C $$d;    \
-       done
-
-.PHONY: install install-libs install-program
-install: install-libs install-program
-
-install-program: SUBDIRS_PROGRAMS
-       $(INSTALL_DIR) $(DESTDIR)$(SBINDIR)
-       $(INSTALL_PROG) xenstored/oxenstored $(DESTDIR)$(SBINDIR)
+all: subdirs-all
 
-install-libs: SUBDIRS_LIBS
+.PHONY: install
+install: subdirs-install
 
 .PHONY: clean
-clean:
-       @for dir in $(SUBDIRS); do \
-               $(MAKE) --no-print-directory -C $$dir clean; \
-       done
+clean: subdirs-clean
index 064d4f67c33c8d3675a4d643c50e079d4de8d8b6..f45a3e45bba58e1a2539ac2f3d9554042b555a03 100644 (file)
@@ -17,13 +17,8 @@ OCAMLOPTFLAG_G := $(shell $(OCAMLOPT) -h 2>&1 | sed -n 's/^  *\(-g\) .*/\1/p')
 OCAMLOPTFLAGS = $(OCAMLOPTFLAG_G) -ccopt "$(LDFLAGS)" -dtypes $(OCAMLINCLUDE) -cc $(CC) -w F -warn-error F
 OCAMLCFLAGS += -g $(OCAMLINCLUDE) -w F -warn-error F
 
-#LDFLAGS = -cclib -L./
-
-DESTDIR ?= /
 VERSION := 4.1
 
-OCAMLABI = $(shell $(OCAMLC) -version)
-OCAMLLIBDIR = $(shell $(OCAMLC) -where)
-OCAMLDESTDIR ?= $(OCAMLLIBDIR)
+OCAMLDESTDIR ?= $(DESTDIR)$(shell ocamlfind printconf destdir)
 
 o= >$@.new && mv -f $@.new $@
diff --git a/tools/ocaml/libs/Makefile b/tools/ocaml/libs/Makefile
new file mode 100644 (file)
index 0000000..2a50a31
--- /dev/null
@@ -0,0 +1,16 @@
+XEN_ROOT = ../../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+SUBDIRS= \
+       uuid mmap \
+       log xc eventchn \
+       xb xs xl
+
+.PHONY: all
+all: subdirs-all
+
+.PHONY: install
+install: subdirs-install
+
+.PHONY: clean
+clean: subdirs-clean
index 60b66f28472f0405a395c1b8f6f443b2affc94b6..ad017a1a93aa34ef405deedfcf7dc55877ce135f 100644 (file)
@@ -19,11 +19,13 @@ OCAML_LIBRARY = eventchn
 
 .PHONY: install
 install: $(LIBS) META
-       ocamlfind install -destdir $(DESTDIR)$(shell ocamlfind printconf destdir) -ldconf ignore eventchn META $(INTF) $(LIBS) *.a *.so *.cmx
+       mkdir -p $(OCAMLDESTDIR)
+       ocamlfind remove -destdir $(OCAMLDESTDIR) eventchn
+       ocamlfind install -destdir $(OCAMLDESTDIR) -ldconf ignore eventchn META $(INTF) $(LIBS) *.a *.so *.cmx
 
 .PHONY: uninstall
 uninstall:
-       ocamlfind remove eventchn
+       ocamlfind remove -destdir $(OCAMLDESTDIR) eventchn
 
 include $(TOPLEVEL)/Makefile.rules
 
index 2a02629fff46780966e8cee4240f8d359acc5eaa..f6a26d6c927bca2a50cddb3611bfe4589b465b27 100644 (file)
@@ -32,11 +32,13 @@ syslog.mli : syslog.ml
 
 .PHONY: install
 install: $(LIBS) META
-       ocamlfind install -destdir $(DESTDIR)$(shell ocamlfind printconf destdir) -ldconf ignore log META $(INTF) $(LIBS) *.a *.so *.cmx
+       mkdir -p $(OCAMLDESTDIR)
+       ocamlfind remove -destdir $(OCAMLDESTDIR) log
+       ocamlfind install -destdir $(OCAMLDESTDIR) -ldconf ignore log META $(INTF) $(LIBS) *.a *.so *.cmx
 
 .PHONY: uninstall
 uninstall:
-       ocamlfind remove log
+       ocamlfind remove -destdir $(OCAMLDESTDIR) log
 
 include $(TOPLEVEL)/Makefile.rules
 
index 374ef69cfdd9db2fb74dfd27f139a549f66021df..6796d93895423353428a31516a3e5181b11e9068 100644 (file)
@@ -18,11 +18,13 @@ OCAML_LIBRARY = mmap
 
 .PHONY: install
 install: $(LIBS) META
-       ocamlfind install -destdir $(DESTDIR)$(shell ocamlfind printconf destdir) -ldconf ignore mmap META $(INTF) $(LIBS) *.a *.so *.cmx
+       mkdir -p $(OCAMLDESTDIR)
+       ocamlfind remove -destdir $(OCAMLDESTDIR) mmap
+       ocamlfind install -destdir $(OCAMLDESTDIR) -ldconf ignore mmap META $(INTF) $(LIBS) *.a *.so *.cmx
 
 .PHONY: uninstall
 uninstall:
-       ocamlfind remove mmap
+       ocamlfind remove -destdir $(OCAMLDESTDIR) mmap
 
 include $(TOPLEVEL)/Makefile.rules
 
index 136967a9a893d6611c1c77792f5721abcd6039e3..509dd7c5f58b36e4a9a16a3488fa3321f3dd89e5 100644 (file)
@@ -17,11 +17,13 @@ OCAML_NOC_LIBRARY = uuid
 
 .PHONY: install
 install: $(LIBS) META
-       ocamlfind install -destdir $(DESTDIR)$(shell ocamlfind printconf destdir) -ldconf ignore uuid META $(INTF) $(LIBS) *.a *.cmx
+       mkdir -p $(OCAMLDESTDIR)
+       ocamlfind remove -destdir $(OCAMLDESTDIR) uuid
+       ocamlfind install -destdir $(OCAMLDESTDIR) -ldconf ignore uuid META $(INTF) $(LIBS) *.a *.cmx
 
 .PHONY: uninstall
 uninstall:
-       ocamlfind remove uuid
+       ocamlfind remove -destdir $(OCAMLDESTDIR) uuid
 
 include $(TOPLEVEL)/Makefile.rules
 
index c68dc9ed94ba4412ab56c96a6c7f437cb474486c..7e583ea5d325cf445219ed3a675ef8fde2e4b789 100644 (file)
@@ -33,10 +33,12 @@ OCAML_LIBRARY = xb
 
 .PHONY: install
 install: $(LIBS) META
-       ocamlfind install -destdir $(DESTDIR)$(shell ocamlfind printconf destdir) -ldconf ignore xb META $(INTF) $(LIBS) *.a *.so *.cmx
+       mkdir -p $(OCAMLDESTDIR)
+       ocamlfind remove -destdir $(OCAMLDESTDIR) xb
+       ocamlfind install -destdir $(OCAMLDESTDIR) -ldconf ignore xb META $(INTF) $(LIBS) *.a *.so *.cmx
 
 .PHONY: uninstall
 uninstall:
-       ocamlfind remove xb
+       ocamlfind remove -destdir $(OCAMLDESTDIR) xb
 
 include $(TOPLEVEL)/Makefile.rules
index b0b0bcc4ab94e0109f13987982a450d54f98c7e6..aca086b3d9f59fc8b0d5bb84f186b15a5c9b5f94 100644 (file)
@@ -20,10 +20,12 @@ libs: $(LIBS)
 
 .PHONY: install
 install: $(LIBS) META
-       ocamlfind install -destdir $(DESTDIR)$(shell ocamlfind printconf destdir) -ldconf ignore xc META $(INTF) $(LIBS) *.a *.so *.cmx
+       mkdir -p $(OCAMLDESTDIR)
+       ocamlfind remove -destdir $(OCAMLDESTDIR) xc
+       ocamlfind install -destdir $(OCAMLDESTDIR) -ldconf ignore xc META $(INTF) $(LIBS) *.a *.so *.cmx
 
 .PHONY: uninstall
 uninstall:
-       ocamlfind remove xc
+       ocamlfind remove -destdir $(OCAMLDESTDIR) xc
 
 include $(TOPLEVEL)/Makefile.rules
diff --git a/tools/ocaml/libs/xl/META.in b/tools/ocaml/libs/xl/META.in
new file mode 100644 (file)
index 0000000..9c4405a
--- /dev/null
@@ -0,0 +1,4 @@
+version = "@VERSION@"
+description = "Xen Toolstack Library"
+archive(byte) = "xl.cma"
+archive(native) = "xl.cmxa"
index 2061e25a925e79a8d864e4cc7af7da8c9d275cd7..f04e7c740d7a6b6f49b81e163b93e6bb2195af6f 100644 (file)
@@ -17,10 +17,12 @@ libs: $(LIBS)
 
 .PHONY: install
 install: $(LIBS) META
-       ocamlfind install -destdir $(DESTDIR)$(shell ocamlfind printconf destdir) -ldconf ignore xl META $(INTF) $(LIBS) *.a *.so *.cmx
+       mkdir -p $(OCAMLDESTDIR)
+       ocamlfind remove -destdir $(OCAMLDESTDIR) xl
+       ocamlfind install -destdir $(OCAMLDESTDIR) -ldconf ignore xl META $(INTF) $(LIBS) *.a *.so *.cmx
 
 .PHONY: uninstall
 uninstall:
-       ocamlfind remove xl
+       ocamlfind remove -destdir $(OCAMLDESTDIR) xl
 
 include $(TOPLEVEL)/Makefile.rules
index 266560f1ab7c3e6d4516fc7dfe006520261f2d4c..31a9646f23c6fcf35c401d90a303eba6c102c0f6 100644 (file)
@@ -33,11 +33,13 @@ OCAML_NOC_LIBRARY = xs
 
 .PHONY: install
 install: $(LIBS) META
-       ocamlfind install -destdir $(DESTDIR)$(shell ocamlfind printconf destdir) -ldconf ignore xs META $(INTF) xs.mli xst.mli xsraw.mli $(LIBS) *.a *.cmx
+       mkdir -p $(OCAMLDESTDIR)
+       ocamlfind remove -destdir $(OCAMLDESTDIR) xs
+       ocamlfind install -destdir $(OCAMLDESTDIR) -ldconf ignore xs META $(INTF) xs.mli xst.mli xsraw.mli $(LIBS) *.a *.cmx
 
 .PHONY: uninstall
 uninstall:
-       ocamlfind remove xs
+       ocamlfind remove -destdir $(OCAMLDESTDIR) xs
 
 include $(TOPLEVEL)/Makefile.rules
 
index fc351d6829f20174c4cd9bdaa3b064b2bdd2adde..6b4697d01b90bec810eceef05022c288a66de7e7 100644 (file)
@@ -52,4 +52,8 @@ all: $(INTF) $(PROGRAMS)
 
 bins: $(PROGRAMS)
 
+install: all
+       $(INSTALL_DIR) $(DESTDIR)$(SBINDIR)
+       $(INSTALL_PROG) oxenstored $(DESTDIR)$(SBINDIR)
+
 include $(OCAML_TOPLEVEL)/Makefile.rules